<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');

$shopList = Shop::GetAllShops();

$serviceList = Service::GetAll();

//print_r($_POST['service_id']);
$service = null;
//Logs::setLog("==============----------------service||=get||".$_GET['id']);
if( $_GET['id'] != null ){
	//Logs::setLog("==============----------------service||=get");
	$service = Service::GetById( abs( intval( $_GET['id'] ) ) );
}

if ( $_POST ) {
	if( $oauthMap[44] == null){
		exit;
	}
	$service = array();
	$service['service_name'] = $_POST['service_name'];
	$service['service_price'] = $_POST['service_price'];
	$service['service_duration'] = $_POST['service_duration'];
	$service['reset_device_time'] = $_POST['reset_time'];
	$service['shop_id'] = $_POST['shop_id'];
	
	$shop_id = $_POST['shop_id'];
	if( $_POST['service_id'] < 1 ){
		//Logs::setLog("==============----------------service||=create");
		$staffId = Service::Create($service);
	}else{
		$service['id'] = $_POST['service_id'];
		Service::Update($service);
	}
	
	
	redirect( WEB_ROOT . "/service/serviceManage.php?shop_id=$shop_id" );
}



include template('/service/service_edit');
